package com.hou.mqacting.controller;

import com.hou.mqacting.pojo.User;
import com.hou.mqacting.service.MessageSendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/send")
public class TestController {

    @Autowired
    private MessageSendService mseeageSendService;

    @RequestMapping("/str")
    public void sendString(){
        mseeageSendService.sendString("hello rabbitmq");
    }

    @RequestMapping("/obj")
    public void sendObject(){
        User user=new User();
        user.setId("001");
        user.setName("消息对象");
        mseeageSendService.sendObject(user);
    }

    //测试Mandatory参数
    @RequestMapping("/test")
    public void sendTest(){
        mseeageSendService.sendTest();
    }
    //测试备份交换器
    @RequestMapping("/back")
    public void sendBack(){
        mseeageSendService.sendBackExchange();
    }

    //测试过期消息
    @RequestMapping("/ttl")
    public void sendTTL(){
        mseeageSendService.sendTTLMessage();
    }

    //测试优先级队列,发送多条优先级不一样的消息堆积
    @RequestMapping("/pri1/{num}")
    public void sendPri1(@PathVariable("num") Integer num){
        mseeageSendService.sendPri1(num);
    }
    //第二个队列
    @RequestMapping("/pri2/{num}")
    public void sendPri2(@PathVariable("num") Integer num){
        mseeageSendService.sendPri2(num);
    }


    //测试生产者确认机制
    @RequestMapping("/pcom")
    public void sendPCom(){
        mseeageSendService.sendPCom();
    }


}
